import axios from "axios";

import global from "../global/index"

const uri = global.url;

export default class BaseService {
    constructor() {
        this.Request = axios.create({});
    }


    getApi(url, data, headers) {
        let config = {};
        if (typeof (data) !== "undefined") {
            config.params = data
        }
        if (typeof (headers) !== "undefined") {
            config.headers = headers
        }
        return this.Request.get(uri.api + url, config)
    }

    postApi(url, data) {
        return this.Request.post(uri.api + url, data);
    }

    getStorage(name) {
        if (!name) {
            return null;
        }
        return window.localStorage.getItem(name);
    }

    setStorage(name,value) {
        if (!name) {
            return null;
        }
        return window.localStorage.setItem(name,value);
    }

    removeStorage(name) {
        if (!name) {
            return null;
        }
        return window.localStorage.removeItem(name);
    }
}
